package state.group.events;

import messages.ByteList;

public class RegistrationEvent extends ElevatorEvent {
    
    private byte doorOpen;
    private byte lastKnownFloor;
    private byte direction;

    public RegistrationEvent(byte[] data, int startIndex)
    {
        super(data, startIndex);
        this.doorOpen = data[startIndex + 2];
        this.lastKnownFloor = data[startIndex + 3];
        this.direction = data[startIndex + 4];
    }
    
    public RegistrationEvent(byte elevatorId, byte doorOpen, byte lastKnownFloor, byte direction)
    {
        super(elevatorId);
        this.doorOpen = doorOpen;
        this.lastKnownFloor = lastKnownFloor;
        this.direction = direction;
    }
    
    public byte isDoorOpen()
    {
        return doorOpen;
    }
    
    public byte getFloor()
    {
        return lastKnownFloor;
    }
    
    public byte getDirection()
    {
        return direction;
    }
    
    public void appendToByteList(ByteList list)
    {
        super.appendToByteList(list);
        list.addByte(doorOpen);
        list.addByte(lastKnownFloor);
        list.addByte(direction);
    }

    @Override
    public int getEventByteLength()
    {
        return 5;
    }

    @Override
    public EventType getEventType()
    {
        return EventType.RegistrationEvent;
    }
}
